package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xmy.cultivate.entity.*;
import com.xmy.cultivate.service.*;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.PageResult;
import com.xmy.cultivate.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 试用表 前端控制器
 * </p>
 *
 * @author hpiggy
 * @since 2025-06-10
 */
@RestController
@RequestMapping("/api/trialForm")
public class TrialFormController extends BaseController{
    @Autowired
    ITryJobService iTryJobService;
    @Autowired
    IRecruitCertificateService iRecruitCertificateService;
    @Autowired
    IRecruitService iRecruitService;
    @Autowired
    IDistrictService iDistrictService;
    @Autowired
    IRecruitAuditLogService iRecruitAuditLogService;
    @Autowired
    IStaffService iStaffService;
    @Autowired
    IRecruitImageService iRecruitImageService;
    @Autowired
    IRecruitExperienceService iRecruitExperienceService;
    @Autowired
    IOrganizationService iOrganizationService;
    @Autowired
    ISchoolNeedsService iSchoolNeedsService;
    @Autowired
    ITryJobAllocationService iTryJobAllocationService;
    @Autowired
    IPermissionSchoolTeacherService iPermissionSchoolTeacherService;

    @Autowired
    IMqPushService iMqPushService;

    @Autowired
    IRecruitPushLogService iRecruitPushLogService;

    @Autowired
    IQyWeChartPushService iQyWeChartPushService;

    @Autowired
    IAllotTeacherWheelService iAllotTeacherWheelService;

    @Autowired
    IQuarterService iQuarterService;
    @Autowired
    IEstimateDetailsService iEstimateDetailsService;
    @Autowired
    IStationNeedsService  iStationNeedsService;

    @Autowired
    IDepartmentService iDepartmentService;

    @Autowired
    ITrialFormService iTrialFormService;


    /**
     * 试用数据统计
     * @param startDate
     * @param endDate
     */
    @RequestMapping("/trialDataCount")
    public Result tryJobDataCount(
            @RequestParam(value = "startDate",required = false) String startDate,
            @RequestParam(value = "endDate",required = false) String endDate
    ){
        QueryWrapper<TryJob> queryWrapper = new QueryWrapper<>();
        //判断开始时间不能为空
        if (StringUtils.isBlank(startDate)){
            return new Result(Code.OK, null, "请选择开始时间");
        }
        //判断结束时间不能为空
        if (StringUtils.isBlank(endDate)){
            return new Result(Code.OK, null, "请选择结束时间");
        }
        HashMap<String, Object> map = new HashMap<>();

        Long adminIdAccount = this.adminId;
        String schoolId = null;
        // 判断是否是超级管理员
        //1667155660271255552L人事主管
/*        if (adminIdAccount == 1568138350324350975L || adminIdAccount == 1667155660271255552L) {
            schoolId = null;
        } else {
            // 判断是否为permission_school_teacher下的老师

            List<String> schoolIdByTeacherId = iPermissionSchoolTeacherService.getSchoolIdByTeacherId(String.valueOf(adminIdAccount));
            if (schoolIdByTeacherId != null && schoolIdByTeacherId.size()>0){
                schoolId = String.join(",", schoolIdByTeacherId);

            } else {
                schoolId = null;

            }
        }*/


        //获取未点评总数
        Long trialCount = iTrialFormService.count(
                new QueryWrapper<TrialForm>()
                        .eq("pass_type",0)
                        .eq("is_give_up", 0)
                        .eq("type", 1)
                        .eq(StringUtils.isNotBlank(schoolId),"school_id", schoolId)
                        .between("trial_date", startDate, endDate));
        //获取通过总数
        Long trialPassCount = iTrialFormService.count(
                new QueryWrapper<TrialForm>()
                        .eq("pass_type",1)
                        .eq("is_give_up", 0)
                        .eq("type", 1)
                        .eq(StringUtils.isNotBlank(schoolId),"school_id", schoolId)
                        .between("trial_date", startDate, endDate));
        //获取未通过总数
        Long trialNotPassCount = iTrialFormService.count(
                new QueryWrapper<TrialForm>()
                        .eq("pass_type",2)
                        .eq("is_give_up", 0)
                        .eq("type", 1)
                        .eq(StringUtils.isNotBlank(schoolId),"school_id", schoolId)
                        .between("trial_date", startDate, endDate));
        //获取试用自弃总数
        Long trialNotArriveCount = iTrialFormService.count(
                new QueryWrapper<TrialForm>()
                        .eq("pass_type",0)
                        .eq("type", 1)
                        .eq(StringUtils.isNotBlank(schoolId),"school_id", schoolId)
                        .eq("is_give_up",1)
                        .between("trial_date", startDate, endDate));

        //在职总数
        Long  workCount = iTrialFormService.count(
                new QueryWrapper<TrialForm>()
                        .eq("pass_type",1)
                        .eq("type", 1)
                        .eq(StringUtils.isNotBlank(schoolId),"school_id", schoolId)
                        .eq("is_give_up",0)
                        .eq("is_resign",0)
                        .between("is_pass_time", startDate + " 00:00:00", endDate +  " 23:59:59"));
        //离职总数
        Long  notWorkCount = iTrialFormService.count(
                new QueryWrapper<TrialForm>()
                        .eq("pass_type",1)
                        .eq("type", 1)
                        .eq(StringUtils.isNotBlank(schoolId),"school_id", schoolId)
                        .eq("is_give_up",0)
                        .eq("is_resign",1)
                        .between("is_resign_time", startDate + " 00:00:00", endDate +  " 23:59:59"));
        map.put("trialCount",trialCount);
        map.put("trialPassCount",trialPassCount);
        map.put("trialNotPassCount",trialNotPassCount);
        map.put("trialNotArriveCount",trialNotArriveCount);
        map.put("workCount",workCount);
        map.put("notWorkCount",notWorkCount);
//        map.put("tryJobIsPassCount",tryJobIsPassCount);
//        map.put("tryJobNoArriveCount",tryJobNoArriveCount);
        return new Result(Code.OK, map, Code.GET_OK_MSG);
    }

    /**
     * 试用列表
     * @param startDate
     * @param endDate
     * @param name
     * @param type
     * @param pageNum
     * @param pageSize
     */
    @GetMapping("/trialList")
    public Result trialList(@RequestParam(value = "startDate",required = false) String startDate,
                             @RequestParam(value = "endDate",required = false) String endDate,
                             @RequestParam(value = "name",required = false) String name,
                             @RequestParam(value = "type",defaultValue = "0") String type,  // 0待点评   1通过  2未通  3试用自弃 4在职 5离职
                             @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                             @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
        IPage<TrialForm> page = new Page<>( pageNum, pageSize);
        Long adminIdAccount = this.adminId;
        String schoolId = null;
        // 判断是否是超级管理员
        //1667155660271255552L人事主管
/*        if (adminIdAccount == 1568138350324350975L || adminIdAccount == 1667155660271255552L) {
            schoolId = null;
        } else {
            // 判断是否为permission_school_teacher下的老师
            List<String> schoolIdByTeacherId = iPermissionSchoolTeacherService.getSchoolIdByTeacherId(String.valueOf(adminIdAccount));
            if (schoolIdByTeacherId != null || schoolIdByTeacherId.size()>0){
                schoolId = String.join(",", schoolIdByTeacherId);

            }
            else {
                schoolId = null;

            }
        }*/
        IPage<TrialForm> trialFormIPage = iTrialFormService.queryTrialList(page, startDate, endDate, type, name, schoolId);
        List<HashMap<String, Object>> list = new ArrayList<>();
        for (TrialForm trialForm : trialFormIPage.getRecords()) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("id", trialForm.getId());
            map.put("tryJobId", trialForm.getTryJobId());
//            map.put("tryDate", trialForm.getTrialDate());

            Recruit recruit = iRecruitService.getById(trialForm.getRecruitId());
            if (recruit!=null){
                map.put("headImage",recruit.getHeadImage());
                map.put("name",recruit.getName());              //姓名
                map.put("phone",recruit.getPhone());            //手机号
                map.put("age",recruit.getAge());                 //年龄
                map.put("marriage",recruit.getMarriage());       //婚姻
                map.put("education",recruit.getEducation());      //学历
                map.put("stations",recruit.getStations());         //岗位意向
                map.put("schoolName",recruit.getSchoolName());  //大学名称
                map.put("major",recruit.getMajor());             //专业
                map.put("recruitId",recruit.getId());
                if (recruit.getEnterType() == 2) {
                    map.put("recruitFileUrl", recruit.getRecruitFileUrl());
                }
                map.put("enterType", recruit.getEnterType());
            }

            QueryWrapper<EstimateDetails> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("recruit_id", trialForm.getRecruitId());
            queryWrapper.eq("type", 3);
            long count = iEstimateDetailsService.count(queryWrapper);
            Integer evaluate = 0;//0未评价 1已评价
            if (count > 0){
                evaluate = 1;
            }
            map.put("evaluate",evaluate);
            map.put("trialDate",trialForm.getTrialDate());
            map.put("passType",trialForm.getPassType());
            map.put("isGiveUp" ,trialForm.getIsGiveUp());
            map.put("trialComment",trialForm.getComment());
            map.put("isComment",trialForm.getIsComment());
            map.put("giveUpTime",trialForm.getGiveUpTime());
            map.put("isResign",trialForm.getIsResign());
            map.put("isPassTime", trialForm.getIsPassTime()); //转正日期
            map.put("isResignTime", trialForm.getIsResignTime()); //离职日期
            list.add(map);
        }

        return new Result(Code.OK, new PageResult<>(list, page.getTotal(), page.getPages()), Code.GET_OK_MSG);

    }

    @PutMapping("/updateTrial")
    public Result updateTrial(@RequestBody TrialForm trialForm) {
        TrialForm trialForm1 = iTrialFormService.getById(trialForm.getId());
        if (trialForm1 == null){
            return new Result(Code.ERROR, "试用信息不存在");
        }
        if (trialForm.getIsGiveUp() !=  null){
            if (trialForm.getIsGiveUp() == 1) {
                trialForm.setGiveUpTime(LocalDateTime.now());
            }
        }
        if (trialForm.getPassType() != null){
            //1试用通过 2试用不通过
            trialForm.setIsPassTime(LocalDateTime.now());
        }
        if (trialForm.getIsResign() != null){
            //1已离职
            trialForm.setIsResignTime(LocalDateTime.now());
            trialForm.setAuditResignId(this.adminId);
        }
        boolean update = iTrialFormService.updateById(trialForm);
        if (update){
            return new Result(Code.UPDATE_OK, "", "操作成功");
        }
        return new Result(Code.UPDATE_ERROR,"","操作失败");

    }

    /**详情
     *
     * @param id
     * @return
     */
    @GetMapping("/trialDetail")
    public Result trialDetail(@RequestParam(value = "id",required = true) Long id) {
        TrialForm trialForm = iTrialFormService.getById(id);
        if (trialForm == null){
            return new Result(Code.ERROR,"","数据不存在");
        }
        HashMap<String, Object> map = new HashMap<>();

        TryJob tryJob = iTryJobService.getTryJobById(trialForm.getTryJobId());

        if (tryJob != null) {
            map.put("trialDate", trialForm.getTrialDate());  //试用日期
            map.put("trialComment", trialForm.getComment()); //试用评语
            map.put("trialPassType", trialForm.getPassType()); //试用判定
            if (trialForm.getCommentId() != null){
                String trialCommentName = iStaffService.getStaffNameById(trialForm.getCommentId());
                map.put("trialCommentName", trialCommentName); //试用点评人
            }

            String auditResignName = null;
            if (trialForm.getAuditResignId() != null){
                 auditResignName = iStaffService.getStaffNameById(trialForm.getAuditResignId());
                map.put("auditResignName", auditResignName); //执行人
            }
            map.put("isPassTime", trialForm.getIsPassTime()); //转正日期
            map.put("isResignTime", trialForm.getIsResignTime()); //离职日期
            map.put("isResign",trialForm.getIsResign());

            map.put("tryDate", tryJob.getTryDate());   //试岗时间
            String campus = iOrganizationService.getById(tryJob.getSchoolId()).getName();

            String departmentName = null;
            if (tryJob.getDepartmentType() != null){
                if (tryJob.getDepartmentType().equals(2) && tryJob.getDepartmentName() != null){
                    departmentName = tryJob.getDepartmentName();
                }
            }
            if (departmentName != null){
                map.put("campus",departmentName);   //显示部门名称
            }else {
                map.put("campus",campus);   //校区
            }
//            map.put("campus", campus);    //分配校区
//        map.put("passType",tryJob.getPassType());
            map.put("trySatisficing", tryJob.getTrySatisficing());
            map.put("isAppraisal", tryJob.getIsAppraisal());
            map.put("allocateTime", tryJob.getCreatedAt());   //分配时间
            map.put("tryAuditDate", tryJob.getTryAuditDate()); //试岗点评时间
            map.put("notArriveReason", tryJob.getNotArriveReason()); //未到岗原因
            map.put("isArriveJob", tryJob.getIsArriveJob());
            //试岗评语
            map.put("tryComment", tryJob.getTryComment());
            Recruit recruit = iRecruitService.getById(tryJob.getRecruitId());
            if (recruit != null) {
                map.put("id", recruit.getId());
                map.put("headImage", recruit.getHeadImage());   //头像
                map.put("name", recruit.getName());              //姓名
                map.put("phone", recruit.getPhone());            //手机号
                map.put("age", recruit.getAge());                 //年龄
                map.put("stations", recruit.getStations());         //岗位意向
                map.put("marriage", recruit.getMarriage());       //婚姻
                map.put("education", recruit.getEducation());      //学历
                map.put("schoolName", recruit.getSchoolName());  //大学名称
                map.put("major", recruit.getMajor());             //专业
                map.put("passType", recruit.getPassType());    //点评结果
                map.put("score", recruit.getScore());           //点评分数
                map.put("inviteDateTime", recruit.getInviteDateTime()); //面试时间
                map.put("createdAt", recruit.getCreatedAt());  //提交时间
                if (recruit.getEnterType() == 2) {
                    map.put("recruitFileUrl", recruit.getRecruitFileUrl());
                }
                map.put("isPassTime", recruit.getIsPassTime());//是否通过时间
                map.put("comment", recruit.getComment());//点评内容
                map.put("enterType", recruit.getEnterType());
                String provinceName = null;
                String cityName = null;
                String countyName = null;
                if (recruit.getProvinceId() != null) {
                    provinceName = iDistrictService.getById(recruit.getProvinceId()).getDistrict();
                }
                if (recruit.getCityId() != null) {
                    cityName = iDistrictService.getById(recruit.getCityId()).getDistrict();
                }
                if (recruit.getCountyId() != null) {
                    countyName = iDistrictService.getById(recruit.getCountyId()).getDistrict();
                }
                map.put("provinceName", provinceName);
                map.put("cityName", cityName);
                map.put("countyName", countyName);
                //获取证书
                QueryWrapper<RecruitCertificate> queryWrapper = new QueryWrapper<>();
                queryWrapper.eq("recruit_id", recruit.getId());
                queryWrapper.last("limit 1");
                RecruitCertificate recruitCertificate = iRecruitCertificateService.getOne(queryWrapper);
                if (recruitCertificate != null) {
                    map.put("certificate", recruitCertificate.getName());   //证书名
                    //获取证书图片
                    QueryWrapper<RecruitImage> recruitImageQueryWrapper = new QueryWrapper<>();
                    recruitImageQueryWrapper.eq("recruit_id", recruit.getId());
                    recruitImageQueryWrapper.eq("recruit_type_id", recruitCertificate.getId());
                    List<RecruitImage> recruitImageList = iRecruitImageService.list(recruitImageQueryWrapper);
                    if (!recruitImageList.isEmpty()) {
                        List<String> certificateOssImages = new ArrayList<>();
                        for (RecruitImage recruitImage : recruitImageList) {
                            certificateOssImages.add(recruitImage.getOssImage());
                        }
                        map.put("certificateOssImages", certificateOssImages);
                    }
                }
                //获取工作经历
                QueryWrapper<RecruitExperience> recruitExperienceQueryWrapper = new QueryWrapper<>();
                recruitExperienceQueryWrapper.eq("recruit_id", recruit.getId());
                recruitExperienceQueryWrapper.last("limit 1");
                RecruitExperience recruitExperience = iRecruitExperienceService.getOne(recruitExperienceQueryWrapper);
                if (recruitExperience != null) {
                    map.put("experience", recruitExperience.getContent());  //工作经验
                }
                map.put("created_at", recruit.getCreatedAt());    //提交时间
                if (recruit.getInviterId() != null) {
//                    Staff staff = iStaffService.getById(recruit.getInviterId());
                    String invitationName = iStaffService.getStaffNameById(recruit.getInviterId());
                    if (StringUtils.isNotBlank(invitationName)) {
                        map.put("invitationName", invitationName);  //邀约人
                    }
                }
                if (recruit.getEstimateId() != null) {
//                    Staff staff1 = iStaffService.getById(recruit.getEstimateId());
                    String estimate = iStaffService.getStaffNameById(recruit.getInviterId());
                    if (StringUtils.isNotBlank(estimate)) {
                        map.put("estimate", estimate);  //面试官
                    }
                }
                Integer type = 0;
                Integer status = 0; //1拒绝 2接受
                if (recruit.getStatus() == 2 && recruit.getResultStatus() == 2) {
                    type = 4;
                    status = 2;
                }
                //符合（已处理）未邀约
                if (recruit.getStatus() == 1 && recruit.getResultStatus() == 0) {
                    type = 4;
                    status = 1;
                }
                //约面试已邀约
                if (recruit.getInterviewStatus() != null) {
                    if (recruit.getResultStatus() == 1 && recruit.getInterviewStatus() == 1) {
                        type = 3;
                        status = 1;
                    }
                    //拒面试中止
                    if (recruit.getResultStatus() == 2 && recruit.getInterviewStatus() == 2) {
                        type = 3;
                        status = 2;
                    }
                }
                //符合约面试已到
                if (recruit.getIsArrive() != null) {
                    if (recruit.getStatus() == 1 && recruit.getResultStatus() == 1 && recruit.getInterviewStatus() == 1 && recruit.getIsArrive() == 1) {
                        type = 5;
                        status = 2;
                    }
                    //符合约面试未到
                    if (recruit.getStatus() == 1 && recruit.getResultStatus() == 2 && recruit.getInterviewStatus() == 1 && recruit.getIsArrive() == 0) {
                        type = 5;
                        status = 1;
                    }
                }
                RecruitAuditLog recruitAuditLog = iRecruitAuditLogService.selectRecruitAuditLog(status, recruit.getId(), type);
                if (recruitAuditLog != null) {
//                    QueryWrapper<Staff> staffQueryWrapper = new QueryWrapper<>();
//                    staffQueryWrapper.eq("id", recruitAuditLog.getAuditId());
//                    staffQueryWrapper.eq("deleted", 0);
//                    staffQueryWrapper.last("limit 1");
//                    Staff staff = iStaffService.getOne(staffQueryWrapper);
                    String auditName = iStaffService.getStaffNameById(recruitAuditLog.getAuditId());
                    if (StringUtils.isNotBlank(auditName)) {
                        map.put("auditName", auditName);  //获取简历筛选人
                    }
//                    if (staff != null) {
//                        map.put("auditName", staff.getName());  //获取简历筛选人
//                    }
                }
            }

            QueryWrapper<EstimateDetails> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("recruit_id", recruit.getId());
            queryWrapper.eq("type", 2);
            long count = iEstimateDetailsService.count(queryWrapper);
            Integer evaluate = 0;//试岗0未评价 1已评价
            if (count > 0) {
                evaluate = 1;
            }
            map.put("evaluate", evaluate);

            map.put("assessmentScore", tryJob.getScore());   //专业测评分数
            map.put("smallScore",tryJob.getSmallScore());   //小学
            map.put("subjectsId",tryJob.getSubjectsId());
            map.put("trySatisficing", tryJob.getTrySatisficing());
            map.put("tryJobPassType", tryJob.getPassType());
            if (tryJob.getCommentId() != null) {
                String commentName = iStaffService.getStaffNameById(tryJob.getCommentId());
//                QueryWrapper<Staff> staffQueryWrapper = new QueryWrapper<>();
//                staffQueryWrapper.eq("id", tryJob.getCommentId());
//                staffQueryWrapper.eq("deleted", 0);
//                staffQueryWrapper.last("limit 1");
//                Staff staff = iStaffService.getOne(staffQueryWrapper);
//                if (StringUtils.isNotBlank(commentName)) {
                    map.put("commentName", commentName);  //试岗点评
//                }
            }

            if (trialForm.getPassType() == 1 && trialForm.getIsGiveUp() == 0) {
                map.put("process", "通过");  // 进程 1通过
            } else if (trialForm.getPassType() == 2 && trialForm.getIsGiveUp() == 0) {
                map.put("process", "未通过");  // 进程 2未通过
            }  else if (trialForm.getPassType() == 0 && trialForm.getIsGiveUp() == 0) {
                map.put("process", "未点评-待点评");
            } else if (trialForm.getPassType() == 0 && trialForm.getIsGiveUp() == 1) {
                map.put("process", "试用自弃"); //进程 试用自弃
            }
        }
        return new Result(Code.OK, map, Code.GET_OK_MSG);
    }

    /**获取试用最小时间和最大时间
     *
     * @return
     */
    @GetMapping("/trialFormDate")
    public Result trialFormDate(){
        Map<String, Object> stringObjectMap = iTrialFormService.trialFormDate();
        return new Result(Code.OK, stringObjectMap, Code.GET_OK_MSG);
    }


    /**获取转正最小时间和最大时间
     *
     * @return
     */
    @GetMapping("/trialChangeDate")
    public Result trialChangeDate(
                                     ){
        Map<String, Object> stringObjectMap = iTrialFormService.trialChangeDate( );
        //如果为空则返回当前时间
        if (stringObjectMap == null) {
            stringObjectMap = new HashMap<>();
            stringObjectMap.put("startDate", LocalDate.now());
            stringObjectMap.put("endDate", LocalDate.now());
        }
        return new Result(Code.OK, stringObjectMap, Code.GET_OK_MSG);
    }



    /**
     * 试用通过率、转正在职率
     */
    @GetMapping("/trialPassRate")
    public Result trialPassRate(
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "departmentId", required = false) String departmentId, //部门id
            @RequestParam(value = "stationsId", required = false) String stationsId,  //岗位id，多选，多个逗号隔开
            @RequestParam(value = "labourId", required = false) String labourId,
            @RequestParam(value = "type", defaultValue = "") String type,  //校区招：1， 部门招：2
            @RequestParam(value = "theirType", defaultValue = "") String theirType,  //校区：1， 部门：2
            @RequestParam(value = "subjectsId", defaultValue = "") String subjectsId,
            @RequestParam(value = "yearPart", defaultValue = "") String yearPart,
            @RequestParam(value = "quarterNum", defaultValue = "") String quarterNum,
            @RequestParam(value = "dateType", defaultValue = "") String dateType  //1试用通过率  2转正在职率
    ) {
        if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
            startDate = startDate + " 00:00:00";
            endDate = endDate + " 23:59:59";
        }
        List<TrialForm> trialFormList = iTrialFormService.trialPassRate(startDate, endDate, departmentId, stationsId, labourId, type, yearPart, quarterNum, dateType, theirType, subjectsId);

        return new Result(Code.OK, trialFormList, Code.GET_OK_MSG);
    }



    /**
     * 试用通过率详情
     *
     * @param startDate
     * @param endDate
     * @param departmentId
     * @param stationsId
     * @param labourId
     * @param type
     * @param schoolCrossId
     */
    @GetMapping("/trialPassRateDetails")
    public Result trialPassRateDetails(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "departmentId", required = false) String departmentId, //部门id
            @RequestParam(value = "stationsId", required = false) String stationsId,  //岗位id，多选，多个逗号隔开
            @RequestParam(value = "labourId", required = false) String labourId,
            @RequestParam(value = "type", defaultValue = "") String type,  //校区招：1， 部门招：2
            @RequestParam(value = "theirType", defaultValue = "") String theirType,  //校区：1， 部门：2
            @RequestParam(value = "subjectsId", defaultValue = "") String subjectsId,
            @RequestParam(value = "schoolCrossId", required = false) String schoolCrossId,
            @RequestParam(value = "yearPart", defaultValue = "") String yearPart,
            @RequestParam(value = "quarterNum", defaultValue = "") String quarterNum,
            @RequestParam(value = "dateType", defaultValue = "1") String dateType, //
            @RequestParam(value = "recruitStatus", defaultValue = "0") String recruitStatus //0总人数，1试用自弃，2试用通过，3试用淘汰
    ) {
        Page<Recruit> iPage = new Page<>(pageNum, pageSize);
        if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
            startDate = startDate + " 00:00:00";
            endDate = endDate + " 23:59:59";
        }
        iTrialFormService.trialPassRateDetails(iPage, startDate, endDate, departmentId, stationsId, labourId, type, schoolCrossId, yearPart, quarterNum, dateType, recruitStatus, theirType, subjectsId);
        return new Result(Code.OK, new PageResult(iPage.getRecords(), iPage.getTotal(), iPage.getPages()), Code.GET_OK_MSG);
    }

}
